package chixing.day11.homework.work10;


//按折扣率计算
public class DiscountStrategy implements PricingStrategy {
    private double rate;//折扣率

    public DiscountStrategy() {
    }

    public DiscountStrategy(double rate) {
        this.rate = rate;
    }

    //按折扣率计算
    @Override
    public double calculate(Product product) {
        return product.getPrice() * rate;
    }

    public double getRate() {
        return rate;
    }

    public void setRate(double rate) {
        this.rate = rate;
    }

    @Override
    public String toString() {
        return "DiscountStrategy{" +
                "rate=" + rate +
                '}';
    }
}
